package com.exam.service.impl;


import com.exam.dao.IExaminationDao;
import com.exam.entity.Examination;
import com.exam.service.ExaminationService;
import com.github.pagehelper.PageHelper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Service
public class ExaminationServiceImpl implements ExaminationService {

	@Resource
	private IExaminationDao examDao;

	/**
	 * 查询所有考试
	 */
	@Override
	public List<Map<String, Object>> getAllExaminations() {
		return examDao.getAllExaminations();
	}

	/**
	 * 新增一场考试信息
	 * @return
	 */
	@Override
	public int addExamination(Examination examination) {
		return examDao.addExamination(examination);
	}

	/**
	 * 删除一场考试
	 * @param eid	考试编号
	 * @return
	 */
	@Override
	public int delExamination(int eid) {
		return examDao.delExamination(eid);
	}

	/**
	 * 修改考试信息
	 * @return
	 */
	@Override
	public int editExamination(Examination examination) {
		return examDao.editExamination(examination);
	}

	/**
	 * 分页查询考试信息
	 * @param pageNum
	 * @param pageSize
	 * @return
	 */
	@Override
	public List<Map<String, Object>> getExaminationsByPage(String pageNum,String pageSize) {
		PageHelper pageHelper = new PageHelper();
		pageHelper.startPage(Integer.parseInt(pageNum),Integer.parseInt(pageSize));
		return examDao.getExaminationsByPage();
	}

	/**
	 * 总页数
	 * @return
	 */
	@Override
	public int getCountByExamination() {
		return examDao.getCountByExamination();
	}

	/**
	 * 模糊查询 考试  通过考试名称及学生学号
	 * @param ename
	 * @return
	 */
	@Override
	public List<Map<String, Object>> getExaminationByName(String ename) {
		return examDao.getExaminationByName('%'+ename+'%');
	}

	@Override
	public int doImportExam(List<Examination> list) {
		return examDao.doImportExam(list);
	}

	public void setExamDao(IExaminationDao examDao) {
		this.examDao = examDao;
	}
}
